home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / doc / i2tc.awk < prev    next >
Encoding:
AWK Script  |  1996-09-27  |  1.6 KB  |  68 lines

  1. BEGIN {
  2.     #{{{}}}
  3. #    {{{  init chapter counters
  4.     a1=0
  5.     a2=0
  6.     a3=0
  7.     a4=0
  8.     a5=0
  9.     header=1
  10. #    }}}
  11. #    {{{  print auto-gen tag
  12.     printf(".\\%c generated automatically, containing the table of contents\n",34)
  13. #    }}}
  14. #    {{{  print table roff data
  15.     printf(".QP\n")
  16.     printf(".sp\n")
  17.     printf(".sp\n")
  18.     printf(".LG\n")
  19.     printf(".ce\n")
  20.     printf("\\fBContents\\fP\n")
  21.     printf(".iX Contents\n")
  22.     printf(".SM\n")
  23.     printf(".ta 0.4i 4.7i-5mR 4.7iR\n")
  24. #    }}}
  25. }
  26. /^\.tC/ {
  27. #        {{{  print h_skip's
  28.         if ($3=="1")
  29.             printf(".sp 0.5\n")
  30.         else if ($3=="2")
  31.             printf(".if \\n(gR .sp 0.3\n")
  32.         else if ($3=="3")
  33.             printf(".if \\n(gR .sp 0.1\n")
  34. #        }}}
  35.         printf("\t")
  36.         if ($3=="1") printf("\\fB")
  37. #        {{{  print chapter numbers
  38.         if ($3=="1") {
  39.             printf("%d  ",++a1)
  40.             a2=0
  41.         } else if ($3=="2") {
  42.             printf("%d.%d  ",a1,++a2)
  43.             a3=0
  44.         } else if ($3=="3") {
  45.             printf("%d.%d.%d  ",a1,a2,++a3)
  46.             a4=0
  47.         } else if ($3=="4") {
  48.             printf("%d.%d.%d.%d  ",a1,a2,a3,++a4)
  49.             a5=0
  50.         } else
  51.             printf("%d.%d.%d.%d.%d  ",a1,a2,a3,a4,++a5)
  52. #        }}}
  53. #        {{{  print title
  54.         printf("%s",$4)
  55.         for (i=5;;)
  56.          { if ($i=="") break;
  57.              printf(" %s",$i)
  58.              i++
  59.          }
  60. #        }}}
  61.         if ($3=="1") printf("\\fP")
  62.         printf(" %c\t ",header)
  63.         if ($3=="1") printf("\\fB")
  64.         printf("%s",$2)
  65.         if ($3=="1") printf("\\fP")
  66.         printf("\n.br\n")
  67. }
  68.